from typing import List

from pydantic import Field
from tortoise.contrib.pydantic import pydantic_model_creator
from models.address import Address

# 直接生成的模型缺少关联字段
AddressSchema = pydantic_model_creator(Address, name='AddressSchema', exclude_readonly=True)


class AddressSchemaInput(AddressSchema):
    user_id: int
    province_id: int
    city_id: int
    district_id: int
    mobile: str = Field(..., max_length=11, min_length=11, regex=r'^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$')